<template>
	<view>

		<view class="tab_box">
			<u-tabs activeColor='#e34b0f' :barStyle="{backgroundColor:'#e34b0f'}" barWidth="100" inactiveColor='#000' fontSize="30" :list="cate" :bold="false" :is-scroll="false" :current="current" @change="change"></u-tabs>
		    <view class="search">
				<u-search v-model="params.name" @search="getList()" :show-action="false"></u-search>
			</view>
			
		</view>

        <view style="height:92px;"></view>

		<view class="list_box">
			<view class="info" @click="$project.toPath('/pages/fw/mer/info?id='+item.id+'&title='+item.name)" v-for="(item,index) in list" :key="index" >
			    <image class="img" :src="item.image"></image>
				<view class="content_box">
					<view>{{item.name}}</view>
					<view class="site_box">
						<u-icon color="#969696" size="35" name="map"></u-icon>
						<view class="site">{{item.site}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="bitmap" v-if="emptyShow">
			<image :src="none" mode="aspectFit"></image>
			<view class="gray_font fs-13">
				暂无信息~
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				cate: [],
				params: {
					page: 1,
					limit: 10,
					scate_id:'',
					name:''
				},
				list: [],
				total: 0,
				emptyShow: false,
				none:''
			}
		},
		onShow() {
			
		},
		onLoad(e) {
			if(e.title){
				uni.setNavigationBarTitle({
					title:e.title
				})
			}
			 this.none=this.$imgUrl+'assets/img/none_order.png';
			 this.getCate();
		},
		methods: {
			getCate(){
				this.$get(this.$api.scateList,{},res=>{
					let data=res.data;
					if(data.code==1){
						this.cate=data.data;
						if(data.data.length>0){
							this.params.scate_id=data.data[0].id;
						}
						this.getList();
					}
				});
			},
			change(e) {
				console.log(e);
				this.current = e;
				this.params.scate_id=this.cate[e].id;
				this.getList();
			},
			getList() {
				this.params.page = 1;
				this.$get(this.$api.merList, this.params, res => {
					let data = res.data;

					if (!data.data.data || data.data.data.length < 1) {
						this.emptyShow = true;
					} else {
						this.emptyShow = false;
					}

					this.list = data.data.data;
					this.total = data.data.total;
				});
			},
			onReachBottom() {
				if (this.list.length < this.total) {
					this.params.page++;
					this.$get(this.$api.merList, this.params, res => {
						let data = res.data;
						data.data.data.forEach(ress => {
							this.list.push(ress);
						});
					});
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-tab-item {
		background-color: transparent !important;
		font-size: 30rpx !important;
	}

    .tab_box{
		position: fixed;
		top:0;
		left:0;
		width: 100%;
		z-index: 100;
		background-color: white;
	}

	.list_box {
		box-sizing: border-box;
		padding: 0 25rpx;
	}

	.info {
		margin-top:25rpx;
		background-color: white;
		border-radius:30rpx;
	}

    .img{
		width: 100%;
		border-radius: 30rpx 30rpx 0 0;
		height: 400rpx;
		vertical-align: middle;
	}
	
	.content_box{
		box-sizing: border-box;
		padding:25rpx 30rpx;
	}
	
	.site_box{
		display: flex;
		align-items: center;
		font-size: 26rpx;
		margin-top: 15rpx;
		color: #414141;
	}
	.site{
		margin-left:8rpx;
	}
	.bitmap {
		margin-top: 10vh;
		text-align: center;
	}
	.flex{
		display: flex;
		align-items: center;
	}
	.f_s{
		display: flex;
		justify-content: space-between;
	}
	.f_c_s{
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.search{
		box-sizing: border-box;
		padding: 20rpx 20rpx;
	}
</style>